package com.longway.core.toolbox.wdp;

import com.longway.core.toolbox.wdp.api.AuthorizationInfoFactory;
import com.longway.core.toolbox.wdp.api.DbAuthorizationInfoFactory;
import com.longway.core.toolbox.wdp.msg.IAuthParser;
import com.longway.core.toolbox.wdp.msg.IMsgParser;
import com.longway.core.toolbox.wdp.msg.JsonMsgParser;
import com.longway.core.toolbox.wdp.msg.XmlAuthParser;
import com.longway.core.toolbox.wdp.msg.XmlMsgParser;


/**
 * 三方平台配置工具
 */
public class WdpConfigKit {
	private static WdpConfig wdpConfig;

	/**
     * 小程序消息解析
     */
    private static IMsgParser msgParser = new XmlMsgParser();
    
    /**
     * 小程序授权解析
     */
    private static IAuthParser authParser = new XmlAuthParser();
    
    /**
     * 授权信息工厂
     */
    private static AuthorizationInfoFactory authorizationFactory = DbAuthorizationInfoFactory.me(); 
    /**
     * 获取小程序消息解析器
     * @return {IMsgParser}
     */
    public static IMsgParser getMsgParser() {
        return msgParser;
    }
    
    
    public static IAuthParser getAuthParser() {
		return authParser;
	}


	/**
     * 获取授权信息
     */
    public static AuthorizationInfoFactory getAuthorizationInfoFactory() {
        return authorizationFactory;
    }
    /**
     * 设置小程序消息解析器
     */
    public static void useJsonMsgParser() {
        WdpConfigKit.msgParser = new JsonMsgParser();
    }

    // 开发模式将输出消息交互 xml、json 到控制台
    private static boolean devMode = false;

    public static void setDevMode(boolean devMode) {
        WdpConfigKit.devMode = devMode;
    }

    public static boolean isDevMode() {
        return devMode;
    }
    
    public static WdpConfig getWdpConfig() {
		return wdpConfig;
	}
	public static void setWdpConfig(WdpConfig wdpConfig) {
		WdpConfigKit.wdpConfig = wdpConfig;
	}
}
